package org.projsquirrel;

import java.io.FileOutputStream;
import java.io.PrintWriter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class ShareComment extends Activity{
	Button share;
	EditText comment,title;
	String FILENAME = "data_file";
	@Override
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sharecomment);
        comment=(EditText) findViewById(R.id.commenttext);
        title=(EditText) findViewById(R.id.titletext);
        share=(Button) findViewById(R.id.sharebutton);
        this.setTitle("Share Comments");
        share.setOnClickListener(new OnClickListener() {
  //          @Override
            public void onClick(View v) {
            	Editable txttitle = title.getText();
            	Editable txtcomment = comment.getText();
            	try {
            	FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
            	PrintWriter out = new PrintWriter(fos);
            	out.write(txttitle.toString()+","+txtcomment.toString());
            	fos.close();
            	out.close();
            	}
            	catch(Exception e) {
            		e.printStackTrace();
            	}
            	Toast toast = Toast.makeText(getApplicationContext(),"Your Comment is Updated.",1);
            	toast.show();
            	Intent intent = new Intent(ShareComment.this,ProjectSquirrel.class);
            	ShareComment.this.startActivity(intent); 
            }
        });
     }
}

